package 定义学生类覆盖Object中的方法实现Comparable接口;

import java.util.Arrays;
import java.util.Scanner;

//定义一个学生类Student，成员变量包括：姓名，生日，学号，学校；重写方法toString，equals，hashCode；
// 实现接口Comparable，按照学号大小进行比较；定义构造方法。
public class Main{
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int num=in.nextInt();
        Student[] studentArray = new Student[num];
        for(int i=0;i<num;i++)
        {
            String name=in.next();
            int year=in.nextInt();
            int month=in.nextInt();
            int day=in.nextInt();
            String studentId=in.next();
            String school=in.next();
            studentArray[i]=new Student(name,year,month,day,studentId,school);
        }

        Arrays.sort(studentArray);
        for(Student s:studentArray)
            System.out.println(s);
    }
}
class Student implements Comparable
{//year,month,day,studentId,school
    private String name;
    private int year;
    private int month;
    private int day;
    private String studentId;
    private String school;

    public Student() {
    }

    public Student(String name, int year, int month, int day, String studentId, String school) {
        this.name = name;
        this.year = year;
        this.month = month;
        this.day = day;
        this.studentId = studentId;
        this.school = school;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    public int getMonth() {
        return month;
    }

    public void setMonth(int month) {
        this.month = month;
    }

    public int getDay() {
        return day;
    }

    public void setDay(int day) {
        this.day = day;
    }

    public String getStudentId() {
        return studentId;
    }

    public void setStudentId(String studentId) {
        this.studentId = studentId;
    }

    public String getSchool() {
        return school;
    }

    public void setSchool(String school) {
        this.school = school;
    }

    @Override
    public boolean equals(Object obj) {
        Student n=(Student) obj;
        return studentId.equals(n.getStudentId());
    }

    @Override
    public int hashCode() {
        return studentId.hashCode();
    }

    @Override
    public String toString() {
        String month1=String.format("%02d",month);
        String day1=String.format("%02d",day);
        return "Student[name="+name+", birthday="+year+"-"+month1+"-"+day1+", studentId="+studentId+", school="+school+"]";
    }

    @Override
    public int compareTo(Object o) {
        Student n=(Student) o;
        return studentId.compareTo(n.getStudentId());
    }
}